<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home-page></home-page>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp();
    const CommonTitle = {
      template: `
        <div>
          <h2>子组件</h2>  
          {{a}}
          {{ b }}
          {{ c }}
        </div>
      `,
      inject: ['a', 'b', 'c']
    }
    const HomePage = {
      template: `
        <div>
          <h1>首页</h1>  
          <common-title></common-title>

        </div>
      `,
      // 向子组件提供依赖
      provide: {
        a:"a数据",
        b: 10,
        c: 'c数据'
      },
      components: {
        CommonTitle
      }
    }

    app.component('HomePage', HomePage)
    app.mount('#app')
  </script>
</body>
</html>